package com.spring.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.spring.controller.DbProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration//当前类为配置类
public class JdbcConfig {

//    @Value("${jdbc.url}")
//    String url;
//    @Value("${jdbc.driverClassName}")
//    String driverClassName;
//    @Value("${jdbc.username}")
//    String username;
//    @Value("${jdbc.password}")
//    String password;

    @Autowired
    private DbProperties dbProperties;

//    @Bean
   // @ConfigurationProperties(prefix = "jdbc")
//    public DruidDataSource druidDataSource(){
//        DruidDataSource druidDataSource = new DruidDataSource();
//        druidDataSource.setUrl(dbProperties.getUrl());
//        druidDataSource.setDriverClassName(dbProperties.getDriverClassName());
//        druidDataSource.setUsername(dbProperties.getUsername());
//        druidDataSource.setPassword(dbProperties.getPassword());
//        return druidDataSource;
//    }



}
